home *** CD-ROM | disk | FTP | other *** search
/ The Essential Home & Business Collection / The Essential Home & Business Collection.iso / 27 / 3 / 5 / HP22D5.ZIP / EXTERN / SETPAL.ASM < prev    next >
Assembly Source File  |  1991-04-16  |  3KB  |  184 lines

  1. DOSSEG
  2. .MODEL        LARGE
  3.  
  4. include        extern.inc
  5.  
  6. EXTRN        htoi:FAR
  7. EXTRN        itoh:FAR
  8. EXTRN        _sprintf:FAR
  9. EXTRN        ReturnValue:FAR
  10. EXTRN        stoh:FAR
  11.  
  12. .DATA
  13.  
  14. setreg_name      db        'setreg',0
  15. setpal_name    db        'setpal',0
  16. getpal_name    db        'getpal',0
  17. getreg_name    db        'getreg',0
  18. format        db        "%d,%d,%d",0
  19. buffer        db        20 dup (' ')
  20.  
  21. Pool        PoolStruct    <setreg_name,setreg,,HANDLER>
  22.         PoolStruct    <setpal_name,setpal,,HANDLER>
  23.         PoolStruct    <getpal_name,getpal,,FUNCTION>
  24.         PoolStruct    <getreg_name,getreg,,FUNCTION>
  25.         PoolStruct    <>    ;END
  26.  
  27. .CODE
  28.  
  29. setpal:
  30.         push        bp
  31.         mov        bp,sp
  32.         push        di
  33.  
  34.         cmp byte ptr    [bp+6],4     ;Need color and value
  35.         jne        SP2
  36.         mov        di,20        ;stack offset of blue
  37.  
  38. SP1:        push        di        ;save stack offset
  39.         les        di,[bp+di]    ;ES:DI = hColorValue
  40.         push        es
  41.         push        di
  42.         call        htoi        ;AX = color value
  43.         pop        di        ;get original stack offset
  44.         push        ax        ;save color value on stack
  45.         sub        di,4        ;next parameter
  46.         cmp        di,8        ;done yet?
  47.         jae        SP1
  48.  
  49.         ;there are now four colors on the stack
  50.  
  51.         pop        bx        ;Color Number
  52.         pop        ax        ;red
  53.         mov        dh,al
  54.         pop        ax        ;green
  55.         mov        ch,al
  56.         pop        ax        ;blue
  57.         mov        cl,al
  58.         mov        ax,1010h    ;Set 1 DAC Color
  59.         int        10h
  60.  
  61. SP2:
  62.         pop        di
  63.         pop        bp
  64.         mov        ax,STOP        ;terminate this message
  65.         retf
  66.  
  67. ;
  68. ; This routine sets a color in the palette to another value. For example,
  69. ; if you wanted all of the red to become blue, use the command:
  70. ;
  71. ;    setreg red,blue;
  72. ;
  73. setreg:
  74.         push        bp
  75.         mov        bp,sp
  76.  
  77.         mov        ax,[bp+6]    ;NUMARGS
  78.         cmp        ax,2
  79.         jne        SR1
  80.  
  81.         les        bx,[bp+8]    ;color
  82.         push        es
  83.         push        bx
  84.         call        htoi
  85.         push        ax        ;AX = color
  86.  
  87.         les        bx,[bp+12]
  88.         push        es
  89.         push        bx
  90.         call        htoi
  91.         pop        bx        ;AX = value, BX = color
  92.  
  93.         mov        bh,al
  94.         mov        ax,1000h
  95.         int        10h
  96.  
  97. SR1:
  98.         mov        ax,STOP
  99.         pop        bp
  100.         retf
  101.  
  102. getpal:
  103.         push        bp
  104.         mov        bp,sp
  105.         cmp byte ptr    [bp+6],1
  106.         jne        GP1
  107.  
  108.         les        bx,[bp+8]    ;ES:BX = hColorValue
  109.         push        es
  110.         push        bx
  111.         call        htoi        ;AX = color value
  112.  
  113.         mov        bx,ax
  114.         mov        ax,1015h
  115.         int        10h
  116.  
  117.         xor        ah,ah        ;AH = 0
  118.         mov        al,cl        ;AX = blue
  119.         push        ax
  120.  
  121.         mov        al,ch        ;AX = green
  122.         push        ax
  123.  
  124.         mov        al,dh        ;AX = red
  125.         push        ax
  126.  
  127.         push        ds
  128.         mov        ax,offset format
  129.         push        ax
  130.  
  131.         push        ds
  132.         mov        ax,offset buffer
  133.         push        ax
  134.  
  135.         call        _sprintf
  136.         add        sp,14
  137.  
  138.         push        ds
  139.         mov        ax,offset buffer
  140.         push        ax
  141.         call        stoh
  142.  
  143.         push        dx
  144.         push        ax
  145.         call        ReturnValue
  146.  
  147. GP1:        
  148.         mov        ax,STOP
  149.         pop        bp
  150.         retf
  151.  
  152. getreg:
  153.         push        bp
  154.         mov        bp,sp
  155.         cmp byte ptr    [bp+6],1
  156.         jne        GR1
  157.  
  158.         les        bx,[bp+8]    ;ES:BX = hColorValue
  159.         push        es
  160.         push        bx
  161.         call        htoi        ;AX = color value
  162.  
  163.         mov        bx,ax
  164.         mov        ax,1007h
  165.         int        10h
  166.  
  167.         mov        bl,bh
  168.         xor        bh,bh
  169.         push        bx
  170.  
  171.         call        itoh
  172.         push        dx
  173.         push        ax
  174.         call        ReturnValue
  175.  
  176. GR1:        
  177.         mov        ax,STOP
  178.         pop        bp
  179.         retf
  180.  
  181. END
  182.  
  183.  
  184.